Python/Python MCQs Sample Test,Sample questions

Question:
 In which year was the Python 3.0 version developed?

1.2008

2.2000

3.2010

4.2005

Posted Date:-2021-01-22 09:02:56


Question:
 Which one of the following has the highest precedence in the expression?

1.Division

2.Subtraction

3.Power

4. Parentheses

Posted Date:-2021-01-22 09:02:56


Question:
How is a function declared in Python?

1.def function function_name():

2.declare function function_name():

3.def function_name():

4.declare function_name():

Posted Date:-2021-01-22 09:02:56


Question:
If return statement is not used inside the function, the function will return:

1.None

2.0

3.Null

4.Arbitary value

Posted Date:-2021-01-22 09:02:56


Question:
In which language is Python written?

1. English

2.PHP

3.C

4.All of the above

Posted Date:-2021-01-22 09:02:56


Question:
In which part of memory does the system stores the parameter and local variables of funtion call?

1.heap

2.stack

3.Uninitialized data segment

4.None of the above

Posted Date:-2021-01-22 09:02:56


Question:
In which year was the Python language developed?

1.1995

2.1972

3.1981

4.1989

Posted Date:-2021-01-22 09:02:56


Question:
What is the maximum possible length of an identifier?

1.16

2.32

3.64

4.None of these above

Posted Date:-2021-01-22 09:02:56


Question:
Lambda is a function in python?

1.TRUE

2.FALSE

3.Lambda is a function in python but user can not use it.

4.None of the above

Posted Date:-2021-01-22 09:02:56


Question:
Study the following code: >>>"javatpoint"[5:]   What will be the output of this code?

1.javatpoint

2. java

3.point

4.None of these

Posted Date:-2021-01-22 09:02:56


Question:
Study the following code: x = ['XX', 'YY']  
for i in a:  
    i.lower()  
print(a)   What will be the output of this program?

1.['XX', 'YY']

2.['xx', 'yy']

3.[XX, yy]

4.None of these

Posted Date:-2021-01-22 09:02:56


Question:
Study the following function: all([2,4,0,6])  What will be the output of this function?

1. False

2.TRUE

3.0

4. Invalid code

Posted Date:-2021-01-22 09:02:56


Question:
Study the following function: import math  
abs(math.sqrt(36))   What will be the output of this code?

1.Error

2.#VALUE!

3.6

4.6

Posted Date:-2021-01-22 09:02:56


Question:
Study the following function:any([5>8, 6>3, 3>1])   What will be the output of this code?

1.FALSE

2. True

3.Invalid code

4.None of these

Posted Date:-2021-01-22 09:02:56


Question:
Study the following function:round(4.576)   What will be the output of this function?

1.4

2.5

3.576

4.5

Posted Date:-2021-01-22 09:02:56


Question:
Study the following program: a = 1  
while True:  
    if a % 7 = = 0:  
        break  
    print(a)  
    a += 1   Which of the following is correct output of this program? 

1.1 2 3 4 5

2.1 2 3 4 5 6

3.1 2 3 4 5 6 7

4.Invalid syntax

Posted Date:-2021-01-22 09:02:56


Question:
Study the following program: i = 0  
while i < 5:  
    print(i)  
    i += 1  
    if i == 3:  
        break  
else:  
    print(0)   What will be the output of this statement?

1. 1 2 3

2.0 1 2 3

3. 0 1 2

4. 3 2 1

Posted Date:-2021-01-22 09:02:56


Question:
Study the following program: i = 1:  
while True:  
    if i%3 == 0:  
        break  
    print(i)   Which of the following is the correct output of this program?

1.1 2 3

2.3 2 1

3.1 2

4.Invalid syntax

Posted Date:-2021-01-22 09:02:56


Question:
Study the following program: x = 1  
while True:  
    if x % 5 = = 0:  
        break  
    print(x)   
    x + = 1   What will be the output of this code?

1.error

2.2 1

3.0 3 1

4.None of these

Posted Date:-2021-01-22 09:02:56


Question:
Study the following program: x = ['xy', 'yz']  
for i in a:  
    i.upper()  
print(a)   Which of the following is correct output of this program?

1.['xy', 'yz']

2. ['XY', 'YZ']

3.[None, None]

4.None of these

Posted Date:-2021-01-22 09:02:56


Question:
Study the following statement: >>>"a"+"bc"   What will be the output of this statement?

1. a+bc

2.abc

3.a bc

4.a

Posted Date:-2021-01-22 09:02:56


Question:
Study the following statements: >>> print(0xA + 0xB + 0xC)  What will be the output of this statement?

1.33

2.63

3. 0xA + 0xB + 0xC

4.None of these

Posted Date:-2021-01-22 09:02:56


Question:
Study the following statements: >>> print(ord('h') - ord('z'))   What will be the output of this statement?

1.18

2.-18

3.17

4.-17

Posted Date:-2021-01-22 09:02:56


Question:
Study the following statements: >>> str1 = "javat"  
>>> str2 = ":"  
>>> str3 = "point"  
>>> str1[-1:]   What will be the output of this statement?

1.t

2.j

3.point

4.Java

Posted Date:-2021-01-22 09:02:56


Question:
The output to execute string.ascii_letters can also be obtained from:?

1.character

2.ascii_lowercase_string.digits

3.lowercase_string.upercase

4.ascii_lowercase+string.ascii_upercase

Posted Date:-2021-01-22 09:02:56


Question:
What do we use to define a block of code in Python language?

1. Key

2. Brackets

3.Indentation

4.None of these

Posted Date:-2021-01-22 09:02:56


Question:
What is a recursive function?

1.A function that calls other function.

2. A function which calls itself.

3.Both A and B

4.None of the above

Posted Date:-2021-01-22 09:02:56


Question:
What is a variable defined outside a function referred to as?

1.local variable

2.global variable

3.static Variable

4.automatic variable

Posted Date:-2021-01-22 09:02:56


Question:
What is called when a function is defined inside a class?

1.class

2. function

3.method

4.module

Posted Date:-2021-01-22 09:02:56


Question:
What is the method inside the class in python language?

1.Object

2.Function

3.Attribute

4.Argument

Posted Date:-2021-01-22 09:02:56


Question:
What is the output of the following program? print(chr(ord(chr(97))))

1.a

2.A

3.97

4.error

Posted Date:-2021-01-22 09:02:56


Question:
What is the output of the following program?z = lambda x : x * x  print(z(6))

1.6

2.36

3.0

4.error

Posted Date:-2021-01-22 09:02:56


Question:
Where is function defined?

1.Module

2.class

3.Another Function

4.All of the above

Posted Date:-2021-01-22 09:02:56


Question:
Which character is used in Python to make a single line comment?

1./

2.//

3. #

4.!

Posted Date:-2021-01-22 09:02:56


Question:
Which keyword is use for function?

1.define

2.fun

3.def

4.function

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following declarations is incorrect in python language?

1.xyzp = 5,000,000

2.x y z p = 5000 6000 7000 8000

3.x,y,z,p = 5000, 6000, 7000, 8000

4.x_y_z_p = 5,000,000

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following declarations is incorrect?

1. _x = 2

2. __x = 3

3.__xyz__ = 5

4.None of these

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following function headers is correct?

1.def fun(a = 2, b = 3, c)

2.def fun(a = 2, b, c = 3)

3.def fun(a, b = 2, c = 3)

4.def fun(a, b, c = 3, d)

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following functions is a built-in function in python language?

1. val()

2.print()

3.print()

4.None of these

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following is correctly evaluated for this function? pow(x,y,z)  

1. (x**y) / z

2. (x / y) * z

3.(x**y) % z

4. (x / y) / z

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following is not a keyword in Python language?

1.val

2. raise

3.try

4.with

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following is the use of id() function in python?

1. Id() returns the size of object.

2.Id() returns the identity of the object.

3.Both A and B

4.None of the above

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following items are present in the function header?

1.function name

2.parameter list

3.return value

4.Both A and B

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following operators is the correct option for power(ab)?

1.a ^ b

2.a**b

3. a ^ ^ b

4. a ^ * b

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following precedence order is correct in Python?

1.Parentheses, Exponential, Multiplication, Division, Addition, Subtraction

2.Multiplication, Division, Addition, Subtraction, Parentheses, Exponential

3.Division, Multiplication, Addition, Subtraction, Parentheses, Exponential

4. Exponential, Parentheses, Multiplication, Division, Addition, Subtraction

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following statements is correct for variable names in Python language?

1. All variable names must begin with an underscore.

2. Unlimited length

3.The variable name length is a maximum of 2.

4.All of the above

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following statements is correct in this python code? class Name:  
    def __init__(javatpoint):  
        javajavatpoint = java  
name1=Name("ABC")  
name2=name1

1.It will throw the error as multiple references to the same object is not possible

2.id(name1) and id(name2) will have same value

3.Both name1 and name2 will have reference to two different objects of class Name

4. All of the above

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following statements is correct regarding the object-oriented programming concept in Python?

1.Classes are real-world entities while objects are not real

2.Objects are real-world entities while classes are not real

3.Both objects and classes are real-world entities

4.All of the above

Posted Date:-2021-01-22 09:02:56


Question:
Which of the following words cannot be a variable in python language?

1. _val

2.val

3.try

4._try_

Posted Date:-2021-01-22 09:02:56


Question:
Which one of the following has the same precedence level?

1.Division, Power, Multiplication, Addition and Subtraction

2.Division and Multiplication

3.Subtraction and Division

4.Power and Division

Posted Date:-2021-01-22 09:02:56


Question:
Which one of the following is incorrect?

1.The variables used inside function are called local variables.

2.The local variables of a particular function can be used inside other functions, but these cannot be used in global space

3.The variables used outside function are called global variables

4.In order to change the value of global variable inside function, keyword global is used.

Posted Date:-2021-01-22 09:02:56


Question:
Which one of the following is the correct extension of the Python file?

1..py

2..python

3..p

4.None of these

Posted Date:-2021-01-22 09:02:56


Question:
Which one of the following is the correct way of calling a function?

1.function_name()

2.call function_name()

3.ret function_name()

4.function function_name()

Posted Date:-2021-01-22 09:02:56


Question:
Which one of the following syntaxes is the correct syntax to read from a simple text file stored in ''d:java.txt''?

1.Infile = open(''d:\java.txt'', ''r'')

2.Infile = open(file=''d:\java.txt'', ''r'')

3.Infile = open(''d:java.txt'',''r'')

4. Infile = open.file(''d:\java.txt'',''r'')

Posted Date:-2021-01-22 09:02:56


Question:
Which operator is used in Python to import modules from packages?

1..

2.*

3.->

4.&

Posted Date:-2021-01-22 09:02:56


Question:
Who developed the Python language?

1.Zim Den

2.Guido van Rossum

3.Niene Stom

4.Wick van Rossum

Posted Date:-2021-01-22 09:02:56


Question:
Why does the name of local variables start with an underscore discouraged?

1.To identify the variable

2.It confuses the interpreter

3.It indicates a private variable of a class

4.None of these

Posted Date:-2021-01-22 09:02:56


More MCQS

  1. Python MCQS - Function
  2. Python MCQS - GUI in python
  3. Python MCQS - Operators
  4. Python MCQS - Data type in python
  5. Python MCQS - loops in python
  6. Python MCQS - Numpy
  7. Python MCQS - sqlite3
  8. Python MCQS - Library
  9. Python MCQS - Pandas
  10. Python MCQs
  11. Dictionary Python MCQ set 1
  12. Dictionary Python MCQ set 2
  13. MCQ For Python Fundamentals
  14. MCQ Introduction to Python Section 1
  15. MCQ Introduction to Python Section 2
  16. MCQ Introduction to Python Section 3
  17. MCQ on Flow of Control in Python Set 1
  18. MCQ on Flow of Control in Python Set 2
  19. MCQ on Python String Set 1
  20. File Handling in Python section 1
  21. File Handling in Python section 2
  22. Python Functions MCQS Set 1
  23. Python Functions MCQS Set 2
  24. MCQ on List in Python
  25. Pandas MCQ Questions Set 1
  26. Pandas MCQ Questions Set 2
  27. Tuple MCQ in Python
  28. Python dataframe MCQ
  29. Python Mcq Set 1
  30. Python Mcq Set 2
  31. Python Mcq Set 3
  32. Python Mcq Set 4
  33. Python Mcq Set 5
  34. Python Mcq Set 6
  35. Python Mcq Set 7
  36. Python Mcq Set 8
  37. Python Mcq Set 9
  38. Python Mcq Set 10
  39. Python Mcq Set 11
  40. Python Mcq Set 12
  41. Python Mcq Set 13
  42. Python Mcq Set 14
  43. Python Mcq Set 15
  44. Python Mcq Set 16
  45. Python Mcq Set 17
  46. Python Mcq Set 18
  47. Python Mcq Set 19
  48. Python Mcq Set 20
  49. Python Mcq Set 21
  50. Python MCQ
  51. Python MCQ Questions with Answer
  52. Test
  53. python mcq question and answer
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!